package com.marchsoft.musicalstore.controller;

import com.marchsoft.musicalstore.entity.SelClassAble;
import com.marchsoft.musicalstore.service.SelClassAbleSer;
import com.marchsoft.musicalstore.util.RequestToJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 源
 * Date: 2019-11-20
 * Time: 22:18
 */
@RestController
@RequestMapping("/selClassAble")
public class SelClassAbleCon {
    @Autowired
    SelClassAbleSer selClassAbleSer;


    //通过id查询个人课表信息

    /**
     * 查询可选课程
     * @param name 课程名
     * @param type 班课类型
     * @param page 页数
     * @param limit 数据条数
     * @param musicType 乐器类型
     * @return
     */
    @RequestMapping("/getAllClass")
    public RequestToJson getAllClassAble(String name,int type,int page,int limit,int musicType){
        List<SelClassAble> allClassAble = selClassAbleSer.getClassAble(name,type,page,limit,musicType);
        RequestToJson requestToJson = new RequestToJson(0,"成功",allClassAble);
        return requestToJson;
    }

    /**
     * 接口属于获取某类性质的分页课程
     * @param type 班课还是专课
     * @param courseId 课程类型id
     * @param page 这是第几页
     * @param limit 多少条数据
     * @return
     */


    @RequestMapping("/getClass")
    public RequestToJson getClassByTypeLimit(int type, int courseId, int page, int limit){

        List<SelClassAble> classByTypeLimit = selClassAbleSer.getClassByTypeLimit(type, courseId, page, limit);
        RequestToJson requestToJson = new RequestToJson(0,"成功",classByTypeLimit);
        return requestToJson;
    }


    /**
     * 班课中具体第二页课程详细信息
     * @param selId 课程id
     * @return
     */
    @RequestMapping(path = "/getOneClass",method = RequestMethod.GET)
    public RequestToJson getOneClass(Integer selId){
        Optional<SelClassAble> oneClass = selClassAbleSer.getOneClass(selId);
        RequestToJson requestToJson = new RequestToJson(0,"成功",oneClass);
        return requestToJson;
    }

    /**
     *班课中具体第二页课程详细信息中获取老师的全部课程
     * @param courId
     * @return
     */
    @RequestMapping(path = "/getCourCatalogue",method = RequestMethod.GET)
    public RequestToJson getCourCatalogue(Integer courId){
        List<SelClassAble> courCatalogue = selClassAbleSer.getCourCatalogue(courId);
        RequestToJson requestToJson = new RequestToJson(0,"成功",courCatalogue);
        return requestToJson;
    }





}
